package com.ui.design.main;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;

import com.alibaba.android.arouter.launcher.ARouter;
import com.ui.design.R;
import com.ui.design.main.adapter.SelectorAdapter;
import com.ui.design.main.base.BaseActivity;
import com.ui.design.main.bean.SelectorBean;
import com.ui.design.main.constants.Constants;

import java.util.ArrayList;
import java.util.List;


public class MainActivity extends BaseActivity {

    private RecyclerView recyclerView;

    @Override
    protected int initLayout() {
        return R.layout.activity_main;
    }

    protected void initView(){
        recyclerView=findViewById(R.id.main_recycler);
        findViewById(R.id.my_blog).setOnClickListener(v ->  ARouter.getInstance().build(Constants.Html).withString("webUrl","https://blog.csdn.net/number_cmd9").navigation());
    }

    protected void initData(){
        List<SelectorBean> selectorBeans=Constants.getSelectorBeans();
        SelectorAdapter selectorAdapter=new SelectorAdapter(MainActivity.this,selectorBeans);
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(MainActivity.this);
        linearLayoutManager.setOrientation(RecyclerView.VERTICAL);
        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setAdapter(selectorAdapter);
    }
}